<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    // 写一个 mySetInterVal(fn, a, b),每次间隔 a,a+b,a+2b,...,a+nb 的时间，然后写一个 myClear，停止上面的 mySetInterVal
    function  mySetInterVal(fn,a,b){
        this.a =a;
        this.b = b;
        this.count = 0;
        this.handle = -1;
        this.start = function(){
            this.handle = setTimeout(()=>{
                this.count++;
                fn();
                this.start()
            },this.a+this.count*this.b)
        }
        this.stop = function(){
            clearTimeout(this.handle)
        }
    }
    let myTimer = new mySetInterVal(()=>{
        console.log('hello')
    },1000,2000)
    myTimer.start()
</script>

</html>